package foo.bar.wiki.plugins;

import foo.bar.wiki.services.*;
import org.springframework.context.ApplicationContext;

/**
 * @author tmjee
 * @version $Date$ $Id$
 */
public class PluginContext {

    private ApplicationContext applicationContext;

    private UserService userService;
    private SetupService setupService;
    private FeedsService feedsService;
    private ThemeService themeService;
    private WikiService wikiService;

    PluginContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    public UserService getUserService() {
        if (userService == null) {
            userService = (UserService) applicationContext.getBean("userService");
        }
        return userService;   
    }

    public SetupService getSetupService() {
        if (setupService == null) {
            setupService = (SetupService) applicationContext.getBean("setupService");
        }
        return setupService;
    }

    public FeedsService getFeedsService() {
        if (feedsService == null) {
            feedsService = (FeedsService) applicationContext.getBean("feedsService");
        }
        return feedsService;
    }

    public ThemeService getThemeService() {
        if (themeService == null) {
            themeService = (ThemeService) applicationContext.getBean("themeService");
        }
        return themeService;
    }

    public WikiService wikiService() {
        if (wikiService == null) {
            wikiService = (WikiService) applicationContext.getBean("wikiService");
        }
        return wikiService;
    }

}
